﻿package test 
{
	import bbv11.tab.menu.TabMenu;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.text.TextField;
	import flash.utils.Timer;
	import igz.fleaxy.Fleaxy;
	import igz.fleaxy.form.textarea.TextAreaUi;
	import igz.fleaxy.locale.LocaleManager;
	import igz.fleaxy.text.ui.LabelUi;
	import igz.fleaxy.text.ui.TextUi;
	import igz.fleaxy.ui.scrollbar.ScrollBarV;
	import igz.fleaxy.ui.scrollbar.ScrollContainerUi;
	import igz.fleaxy.ui.scrollbar.ScrollBarH;
	
	/**
	 * @author Intelygenz | www.intelygenz.com
	 */
	public class Main_Test extends Sprite{
//{
		[Embed(source='../../font/standard09_55.ttf'
				, fontName = "Standard0955", fontStyle = "regular", fontWeight = "normal"
				, mimeType = "application/x-font-truetype"
				, unicodeRange="U+0000-U+00FF,U+20AC"
				)
		]
		public static const Standard0955_N:Class; //Grande

		[Embed(source = '../../font/LTe50422.ttf'
				, fontName = "VAGRoundedLight", fontStyle = "regular", fontWeight = "normal"
				, mimeType = "application/x-font-truetype"
				, unicodeRange="U+0000-U+00FF,U+20AC"
				)
		]
		public static const VAGRoundedLight_N:Class;
		
		[Embed(source = '../../font/trebuc.ttf'
				, fontName = "Trebuchet", fontStyle = "regular", fontWeight = "normal"
				, mimeType = "application/x-font-truetype"
				, unicodeRange="U+0000-U+00FF,U+20AC"
				)
		]
		public static const Trebuchet_N:Class;
		
		[Embed(source = '../../font/trebucbd.ttf'
				, fontName = "Trebuchet", fontStyle = "regular", fontWeight = "bold"
				, mimeType = "application/x-font-truetype"
				, unicodeRange="U+0000-U+00FF,U+20AC"
				)
		]
		public static const Trebuchet_B:Class;
		
		[Embed(source='../../font/trebucit.ttf'
				, fontName = "Trebuchet", fontStyle = "regular", fontWeight = "normal", fontStyle="italic"
				, mimeType = "application/x-font-truetype"
				, unicodeRange="U+0000-U+00FF,U+20AC"
				)
		]
		public static const Trebuchet_I:Class;
		
		[Embed(source='../../font/trebucbi.ttf'
				, fontName = "Trebuchet", fontStyle = "regular", fontWeight="bold", fontStyle="italic"
				, mimeType = "application/x-font-truetype"
				, unicodeRange="U+0000-U+00FF,U+20AC"
				)
		]
		public static const Trebuchet_BI:Class;
//}
		public function Main_Test() {
			/*stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align 	= StageAlign.TOP_LEFT;
			stage.quality   = StageQuality.HIGH;
			stage.showDefaultContextMenu = false;*/

			Fleaxy.$Init( stage, { embedFonts : [Trebuchet_N,Trebuchet_B,Trebuchet_I,Trebuchet_BI,Standard0955_N, VAGRoundedLight_N]//[Standard0751_N, Standard0753_N, Standard0755_N, Standard0955_N, VAGRoundedLight_N]
								 , iso639 	  : "ES"
								 , onComplete : _OnInitComplete
								 }
						);
		}

		
/*private var	_X:int = 250;
private var	_Lines:int = 10;
		private var _H:LabelUi;
		private var _G:Sprite;*/
		
		private var container:ScrollContainerUi;
		
		private function _OnInitComplete() : void {
/*
			var a:LabelUi = new LabelUi("Prueba 1", "test1");
			addChild(a);
			
			var b:TextUi = new TextUi("Prueba 2", "test2");
			addChild(b);
trace("b.htmlText[" + b.htmlText + "]");
			

trace("1 b.htmlText[" + b.htmlText + "]");
			b.$StyleName = "test1";
trace("2 b.htmlText[" + b.htmlText + "]");

			//b.y = a.y + a.height;
			//a.y = b.y + b.height;
			
			//var a:Label = new Label();
			
			var c:LabelUi = new LabelUi("1. ESTO ES UN TEXTO DE UN LABEL CON UNA UNICA LINEA SIN ESTILOS");
			addChild(c);
			c.x = 200;
			
			var d:LabelUi = new LabelUi("1. ESTO ES UN TEXTO DE UN LABEL CON UNA LINEA MAS LARGA<BR />2.CON MAS LINEAS<BR />3.Y OTRA LINEA MAS", "test1");
			addChild(d);
			d.y = 100;
			d.x = 200;
			d.background = true;
			d.backgroundColor = 0xDDDDDD;
			
			var e:LabelUi = new LabelUi("SOLO HAY UNA LINEA QUE NO PUEDE SOBREPASAR LOS 200 PX", "test1", {maxWidth:200});
			addChild(e);
			e.y = d.y + d.height;
			e.height = 10;
trace("e.numLines _ " + e.numLines)

			var f:LabelUi = new LabelUi("Solo hay una línea que no <B>PUEDE</B> SOBREPASAR LOS 200 PX <BR />Y ESTO ES OTRA LINEA", "test1", {fixWidth:250, maxLines:1});
			addChild(f);
			f.y = e.y + e.height;
trace("f.numLines _ " + f.numLines)
			
			
			
			_G.y = f.y + f.height;
			
			_H = new LabelUi("Solo hay una línea que no <B>PUEDE</B> SOBREPASAR LOS 200 PX Solo hay una línea que no <B>PUEDE</B> SOBREPASAR LOS 200 PX <SPAN class='test2'>Esto</SPAN> <SPAN class='test1'>es una linea</SPAN><BR />Otra <b>linea</b> <i>más</i> y mas texto normal <B></I>y fin de linea</I></B><br />Texto normal, <B>Negrita</B>, <i>cursiva</i>, <i><b>negrita y cursiva</b></i>SOBREPASAR LOS 250 PX <BR />Y ESTO ES OTRA LINEA MAS Y MAS TEXTO Y MAS TEXTO Y MAS TEXTO Y MAS TEXTO Y MAS TEXTO Y MAS TEXTO<BR /> Y MAS TEXTO Y MAS TEXTO Y MAS TEXTO Y MAS TEXTO<BR />"
			, "test3", {fixWidth:1000, maxLines:1});
			addChild(_H);
			_H.y = _G.y + _G.height + 5;

			var timer:Timer = new Timer(100);
			timer.addEventListener(TimerEvent.TIMER, _OnTimer);
			//timer.start();
			
			var timer2:Timer = new Timer(500);
			timer2.addEventListener(TimerEvent.TIMER, _OnTimer2);
			//timer2.start();
			
			var u:LabelUi = new LabelUi("Solo hay una línea que no <B>PUEDE</B> SOBREPASAR LOS 200 PX <BR />Y ESTO ES OTRA LINEA", "test4", { fixWidth:400, maxLines:10 } );
			addChild(u);
			u.y = _H.y + _H.height;
			
			
			var w:LabelUi = new LabelUi(LocaleManager.$GetText("TEST", "PANTALLA_INTRODUCCION"), "test4", { fixWidth:200,maxLines:3 } );
			addChild(w);
			w.y = 200;
			
			var x:LabelUi = new LabelUi(LocaleManager.$GetText("TEST","PANTALLA_INTRODUCCION"), "test3", {maxLines:3} );
			addChild(x);
			x.y = 400;
trace("x.htmlText["+x.htmlText+"]")
			
			_G = new Sprite();
			_G.graphics.clear();
			_G.graphics.beginFill(0x000000);
			_G.graphics.drawRect(0, 0, 200, 10);
			_G.graphics.endFill();
			_G.y = 190;
			addChild (_G);*/
		/*	
			container = new ScrollContainerUi();
			addChild(container);
			container.x = 100;
			container.y = 100;
			
			var x:LabelUi = new LabelUi(LocaleManager.$GetText("TEST","PANTALLA_INTRODUCCION"), "test4",{fixWidth:500} );
			container.addChild(x);
			
			var scrollV:ScrollBarV = new ScrollBarV(container,"scroll");
			
			var scrollH:ScrollBarH = new ScrollBarH(container,"scroll");
			
			container.x = 50;
			container.y = 50;
			container.width = 200;
			container.height = 100;
			
			var xx:LabelUi = new LabelUi(LocaleManager.$GetText("TEST","PANTALLA_INTRODUCCION"), "test3",{fixWidth:500} );
			xx.y = x.y + x.height;
			container.addChild(xx);
			
			container.$Clear();
			//container.addChild(xx);
			
			var timerAdd:Timer = new Timer(1000,10);
			timerAdd.addEventListener(TimerEvent.TIMER, _OnContainer_Add);
			timerAdd.start();
			
			var ff:TextAreaUi = new TextAreaUi("", { width: 100
										, height: 100
										, label: ""
										, labelStyle: ""
										, textStyle: ""
										, scrollStyle: ""
										, value: "texto de ejemplo"
										});
			addChild(ff);

		}
		
		private var nextY:Number = 0;
		
		private function _OnContainer_Add(p_event:Event):void {
			var xx:LabelUi = new LabelUi(LocaleManager.$GetText("TEST", "PANTALLA_INTRODUCCION"), "test3", { fixWidth:500 } );
			xx.y = nextY;
			nextY = xx.y + xx.height + 5;
			container.addChild(xx);
		}
		*/
		/*private function _OnTimer(p_timerEvent:TimerEvent):void {
trace("_OnTimer["+_X+"]")
			if ( _X > 0 ) {
				_H.$SetFixWidth(_X);
				_X-=5;
			}
			_G.graphics.clear();
			_G.graphics.beginFill(0x000000);
			_G.graphics.drawRect(0, 0, _X, 10);
			_G.graphics.endFill();
		}
		
		private function _OnTimer2(p_timerEvent:TimerEvent):void {
			_H.$SetMaxLines(_Lines);
			if ( _Lines > 0 ) {
				_Lines--;
			}
trace("_OnTimer2[" + _Lines + "]");
		}*/
		
		var json:Object = { "Menu" : { "columns" : [ "Id","IdP","Title" ]
										 , "rows" : [ [1, 0, "1"] 
													, [2, 0, "2"] 
													, [3, 0, "3"] 
													, [11, 1, "1_1"] 
													, [12, 1, "1_2"] 
													, [21, 2, "2_1"] 
													, [31, 3, "3_1"] 
													, [32, 3, "3_2"] 
													, [33, 3, "3_3"] 
													, [34, 11, "34_11"] 
													, [35, 11, "35_11"] 
													, [36, 11, "36_11"] 
													, [37, 11, "37_11"] 
													]
										}
							}; 
		
		//var menu:MenuDynamic = new MenuDynamic();
		//menu.$LoadFromJSON( data );
		
		var menu:TabMenu = new TabMenu();
		menu.$LoadFromJSON( json );
		menu.$Debug();

		menu.$Draw(11);
		
		
		//menu.$AddOption( "1 Pedro");
		//menu.$Recorre();
	}
  }
}